package com.doudou.collection.utils.generator;

/**
 * @ClassName UsernameGenerator
 * @Description 自动生成用户名的工具类
 * @Author blue sky
 * @Date 2023/6/9 23:10
 * @Version 1.0
 */

public class UsernameGenerator {
    private static final String ALPHA_NUMERIC_STRING = "abcdefghijklmnopqrstuvwxyz0123456789";

    public static String generateUsername(String prefix) {
        int count = 10;
        StringBuilder builder = new StringBuilder();
        builder.append(prefix);
        builder.append("-");
        while (count-- != 0) {
            int character = (int)(Math.random()*ALPHA_NUMERIC_STRING.length());
            builder.append(ALPHA_NUMERIC_STRING.charAt(character));
        }
        return builder.toString();
    }
}
